package jvm.heap;

import java.util.ArrayList;
import java.util.Random;

/**
 * @Author: ideaAdmin
 * TODO: 内存溢出 这里是堆空间满了
 *         -XX:SurvivorRatio=8 设置新生代区的Eden 和Survivor的比例是8:1:1
 * Date: 2022/2/20:15:06
 * Description:
 */

public class OOMTest {
    public static void main(String[] args) throws InterruptedException {
        ArrayList<Image> images = new ArrayList<>();

        while (true){
            Thread.sleep(20);
            images.add(new Image(new Random().nextInt(1024*200)));
        }
    }
}

class Image{
    private byte[] bytes;

    public Image(int length ) {
        this.bytes = new byte[length];
    }
}
